/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.core;

import java.awt.BorderLayout;
import java.util.Observer;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Damian
 */
public abstract class CoreFrame extends javax.swing.JFrame implements java.awt.event.ActionListener, Observer {

    public String accountnr, clientName, street, city, zip, state, email, birthdate, numberOfEmployees, accountType, clientType, amountDeposit;
    public boolean newaccount;
    public DefaultTableModel model;
    public JTable JTable1;
    public JScrollPane JScrollPane1;
    public CoreFrame thisframe;
    public Object rowdata[];
    public javax.swing.JPanel JPanel1 = new javax.swing.JPanel();

    public CoreFrame() {

        thisframe = this;
        setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
        getContentPane().setLayout(new BorderLayout(0, 0));
        setSize(600, 340);
        setVisible(false);
        JPanel1.setLayout(null);
        getContentPane().add(BorderLayout.CENTER, JPanel1);
        JPanel1.setBounds(0, 0, 575, 310);
        /*
        /Add five buttons on the pane 
        /for Adding personal account, Adding company account
        /Deposit, Withdraw and Exit from the system
         */

        JButton[] buttons = makeButtons();
        for (int i = 0; i < buttons.length; i++) {
            JPanel1.add(buttons[i]);
        }

        JScrollPane1 = new JScrollPane();
        model = makeTable();
        JTable1 = new JTable(model);
        JPanel1.add(JScrollPane1);
        JScrollPane1.setBounds(12, 92, 444, 160);
        JScrollPane1.getViewport().add(JTable1);
        JTable1.setBounds(0, 0, 420, 0);



    }

    protected abstract DefaultTableModel makeTable();

    protected abstract JButton[] makeButtons();

    void exitApplication() {
        try {
            this.setVisible(false);    // hide the Frame
            this.dispose();            // free the system resources
            System.exit(0);            // close the application
        } catch (Exception e) {
        }
    }

    public class SymWindow extends java.awt.event.WindowAdapter {

        public void windowClosing(java.awt.event.WindowEvent event) {
            Object object = event.getSource();
            if (object == CoreFrame.this) {
            }
            CoreFrame_windowClosing(event);
        }
    }

    public void CoreFrame_windowClosing(java.awt.event.WindowEvent event) {
        // to do: code goes here.

        CoreFrame_windowClosing_Interaction1(event);
    }

    public void CoreFrame_windowClosing_Interaction1(java.awt.event.WindowEvent event) {
        try {
            this.exitApplication();
        } catch (Exception e) {
        }
    }

    @Override
    public abstract void actionPerformed(java.awt.event.ActionEvent event);
}
